#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <iterator>

using namespace std;

#define PRINT_SET(c)\
{\
    for(auto it=c.begin();it!=c.end();it++)\
    {\
        cout<<*it<<" ";\
    }\
    cout<<endl;\
}


int main()
{
    set<int> a,b;
    vector<int> c;

    for(int i=1;i<=6;i++)
    {
    a.insert(i);
    b.insert(2*i);
    } 
    PRINT_SET(a);
    PRINT_SET(b);

    set_union(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    PRINT_SET(c);
    c.clear();

    set_intersection(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    PRINT_SET(c);
    c.clear();

    set_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    PRINT_SET(c);
    c.clear();

    system("pause");
    return 0;
}
